package com.zbu.test;

import java.util.Arrays;

/**
 * 选择排序 从0索引开始，将每一个索引上的元素跟后面的元素一次比较
 */
public class SelectionSort {
    public static void main(String[] args) {
        int[] arr = {14,76,34,94,76,57,36,87,34};
        System.out.println(Arrays.toString(arr));
        for (int i = 0; i < arr.length-1; i++) {
            for (int j = i; j < arr.length-1; j++) {
                if (arr[i] > arr[j+1]){
                    int temp;
                    temp = arr[i];
                    arr[i] = arr[j+1];
                    arr[j+1] = temp;
                }
            }

        }
        System.out.println(Arrays.toString(arr));
    }
}
